The Filters and Function API was added to SciChart WPF v5 as a way to create derived data, filters, indicators or perform functions on your data easily and simply.
SciChart comes with a number of filters built-in. The Filters API can be used easily where you want to
- Add a Linear Trendline to a chart
- Add a Polynomial Trendline to a chart
- Spline interpolate your data to get a smoothed plot
- Perform Low-Pass or High-Pass filtering
- Perform a Moving Average on an underlying DataSeries
- Offset or Scale a data-series
- Perform custom filtering or data transformation operations on your data.
The Filters API is also extremely configurable and allow you to create custom filters - the possibilities of this API really are endless!
Have a look at the video below to show you in more detail what this API is and how you can use it in your applications.
Filters Built-in to SciChart WPF
A number of filters are built-in to the SciChart.Charting library. To use these, we use the Extension Methods in the SciChart.Charting.Model.Filters namespace. Import the namespace using SciChart.Charting.Model.Filters then use one of the following examples below to filter your data.
- Scale, Offset Filters
- Linear Trendline, Polynomial Trendline Filters
- Spline Interpolation Filters
- Moving Average Filters
- Custom Filters
Updating Data with Filters
The beauty of the Filters API is that when the underlying data updates, the filter automatically updates. There is no need to recalculate your filter - SciChart does this for you!
For example, in the WPF Chart Example 'Filters API', we demonstrate a single dataseries with multiple filters. Sliders change the original data. All filters automatically update and the chart updates!

Daisy-Chaining Filters
Fitlers may be daisy chained or cascaded in order to combine their effects. Changing the underlying DataSeries will cause all filters in the chain to trigger an update.
Releasing Filters
The filter extension methods (ToMovingAverage, Scale, Offset, ToSpline, AggregateByCount and the others) create a Filter object implicitly and subscribe it to the original data series' DataSeriesChanged event, so the filtered series keeps updating as the source changes. Because that subscription holds a reference to the Filter, the Filter and its output series stay in memory for as long as the original series lives, even after you stop using them.
When a filtered series is no longer needed, release it to unsubscribe the filter from the original series:
| Releasing a Filter |
Copy Code |
|---|---|
var original = new XyDataSeries<double, double>(); // The extension method creates a filter and subscribes it to 'original' IDataSeries smoothed = original.ToMovingAverage(50); lineSeries.DataSeries = smoothed; // ... later, when the filtered series is no longer needed: original.ReleaseFilter(smoothed); // unsubscribes this one filter; 'smoothed' stops updating | |
To release every filter created directly from a series in a single call, use ReleaseAllFilters:
original.ReleaseAllFilters();
Both methods are safe to call more than once, and ReleaseAllFilters is safe to call when no filters are bound.
After a filter is released, its output series stops receiving updates from the original series.
A note about memory usage
While the Filters API is powerful, we want to make you aware about the memory usage. Each filter creates a copy of a dataseries to store the derived data. This mens that for a 100,000 points DataSeries with one filter applied, 200,000 points are stored in memory.
For TX=Double, TY=Double the total amount of memory required is therefore 200,000 * 8 * 2 = 3.2MBytes (vs. 1.6MBytes for the original data).
Some fitlers use a lot more memory such as the Spline Interpolation filter. With a spline resolution of 5, the derived dataseries will use 5x more memory than the original data-series.
For most applications this won't be a problem, but it's something to bear in mind when filtering your data.